<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>FabGL: examples/LoopbackTerminal/LoopbackTerminal.ino</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">FabGL
   </div>
   <div id="projectbrief">ESP32 VGA Controller and Graphics Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('examples_2_loopback_terminal_2_loopback_terminal_8ino-example.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">examples/LoopbackTerminal/LoopbackTerminal.ino</div>  </div>
</div><!--header-->
<div class="contents">
<p>A description of the example file, causes the example file to show up in Examples</p>
<div class="fragment"><div class="line">/*</div><div class="line">  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - www.fabgl.com</div><div class="line">  Copyright (c) 2018-2019 Fabrizio Di Vittorio.</div><div class="line">  All rights reserved.</div><div class="line"></div><div class="line">  This file is part of FabGL Library.</div><div class="line"></div><div class="line">  FabGL is free software: you can redistribute it and/or modify</div><div class="line">  it under the terms of the GNU General Public License as published by</div><div class="line">  the Free Software Foundation, either version 3 of the License, or</div><div class="line">  (at your option) any later version.</div><div class="line"></div><div class="line">  FabGL is distributed in the hope that it will be useful,</div><div class="line">  but WITHOUT ANY WARRANTY; without even the implied warranty of</div><div class="line">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</div><div class="line">  GNU General Public License for more details.</div><div class="line"></div><div class="line">  You should have received a copy of the GNU General Public License</div><div class="line">  along with FabGL.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</div><div class="line"> */</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">#include &quot;fabgl.h&quot;</div><div class="line"></div><div class="line"></div><div class="line">void print_info()</div><div class="line">{</div><div class="line">  Terminal.write(&quot;\e[37m* * FabGL - Loopback VT/ANSI Terminal\r\n&quot;);</div><div class="line">  Terminal.write(&quot;\e[34m* * 2019 by Fabrizio Di Vittorio - www.fabgl.com\e[32m\r\n\n&quot;);</div><div class="line">  Terminal.printf(&quot;\e[32mScreen Size        :\e[33m %d x %d\r\n&quot;, VGAController.getScreenWidth(), VGAController.getScreenHeight());</div><div class="line">  Terminal.printf(&quot;\e[32mTerminal Size      :\e[33m %d x %d\r\n&quot;, Terminal.getColumns(), Terminal.getRows());</div><div class="line">  Terminal.printf(&quot;\e[32mKeyboard           :\e[33m %s\r\n&quot;, Keyboard.isKeyboardAvailable() ? &quot;OK&quot; : &quot;Error&quot;);</div><div class="line">  Terminal.printf(&quot;\e[32mFree DMA Memory    :\e[33m %d\r\n&quot;, heap_caps_get_free_size(MALLOC_CAP_DMA));</div><div class="line">  Terminal.printf(&quot;\e[32mFree 32 bit Memory :\e[33m %d\r\n\n&quot;, heap_caps_get_free_size(MALLOC_CAP_32BIT));</div><div class="line">  Terminal.write(&quot;\e[32mFree typing test - press ESC to introduce escape VT/ANSI codes\r\n\n&quot;);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line">void setup()</div><div class="line">{</div><div class="line">  // GPIOs for keyboard CLK and DATA</div><div class="line">  Keyboard.begin(GPIO_NUM_33, GPIO_NUM_32);</div><div class="line"></div><div class="line">  // 8 colors</div><div class="line">  //VGAController.begin(GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_19, GPIO_NUM_18, GPIO_NUM_5);</div><div class="line"></div><div class="line">  // 64 colors</div><div class="line">  VGAController.begin(GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_19, GPIO_NUM_18, GPIO_NUM_5, GPIO_NUM_4, GPIO_NUM_23, GPIO_NUM_15);</div><div class="line"></div><div class="line">  VGAController.setResolution(VGA_640x350_70HzAlt1, 640, 350);</div><div class="line"></div><div class="line">  // adjust screen position and size</div><div class="line">  //VGAController.shrinkScreen(5, 0);</div><div class="line">  //VGAController.moveScreen(-1, 0);</div><div class="line"></div><div class="line">  Terminal.begin();</div><div class="line">  Terminal.connectLocally();      // to use Terminal.read(), available(), etc..</div><div class="line"></div><div class="line">  Terminal.setBackgroundColor(Color::Black);</div><div class="line">  Terminal.setForegroundColor(Color::BrightGreen);</div><div class="line">  Terminal.clear();</div><div class="line"></div><div class="line">  print_info();</div><div class="line"></div><div class="line">  Terminal.enableCursor(true);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line">void loop()</div><div class="line">{</div><div class="line">  if (Terminal.available()) {</div><div class="line">    char c = Terminal.read();</div><div class="line">    switch (c) {</div><div class="line">     case 0x7F:       // DEL -&gt; backspace + ESC[K</div><div class="line">       Terminal.write(&quot;\b\e[K&quot;);</div><div class="line">       break;</div><div class="line">     case 0x0D:       // CR  -&gt; CR + LF</div><div class="line">       Terminal.write(&quot;\r\n&quot;);</div><div class="line">       break;</div><div class="line">    default:</div><div class="line">       Terminal.write(c);</div><div class="line">       break;</div><div class="line">    }</div><div class="line">  }</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
